package org.zfes.snowier.cloud.zbss.layer.tc.biz.controller;

import java.util.List;
import java.util.Map;
import java.util.Optional;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.zfes.snowier.core.data.DataSet;
import org.zfes.snowier.core.util.ZStrUtil;
import org.zfes.snowier.web.annos.ListParam;
import org.zfes.snowier.web.controller.BaseController;
import org.zfes.snowier.cloud.zbss.layer.tc.biz.model.SalariedStaff;
import org.zfes.snowier.cloud.zbss.layer.tc.biz.service.ISalariedStaffService;
@Controller 
@RequestMapping("/tcms/salariedStaff")
public class SalariedStaffController extends BaseController {

	private String viewPathPrefix="/tcms";
	
	@Autowired
	private ISalariedStaffService salariedStaffService;
	
	@RequestMapping(value={"/",""}, method = RequestMethod.GET,produces = MediaType.TEXT_HTML_VALUE)
    public Object index(){
		return forward(viewPathPrefix,"salariedStaff.html");
    }
	
	//@RequiresPermissions(value="salariedStaff:loadSalariedStaffList",desc="授薪人员列表")
    @RequestMapping(value="/loadSalariedStaffDataSet", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public @ResponseBody  Object loadSalariedStaffDataSet(@RequestParam Map<String,Object> params){
	    DataSet dataSet=  salariedStaffService.loadSalariedStaffDataSet(params);
	    return dataSet;
    }
	
	//@RequiresPermissions(value="salariedStaff:addSalariedStaff",desc="授薪人员添加")
    @RequestMapping(value="/addSalariedStaff", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public  @ResponseBody Object addSalariedStaff(SalariedStaff salariedStaff){
		salariedStaffService.createSalariedStaff(salariedStaff);
    	return ajaxDoneSuccess("数据操作成功 ");
    }
	
	//@RequiresPermissions(value="salariedStaff:loadSalariedStaff",desc="授薪人员加载")
    @RequestMapping(value="/loadSalariedStaff", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public @ResponseBody  Object loadSalariedStaff(Long id){
		Optional<SalariedStaff> ops = salariedStaffService.loadSalariedStaffById(id);
		return ajaxQuery("salariedStaff",ops);
    }
	
	//@RequiresPermissions(value="salariedStaff:updateSalariedStaff",desc="授薪人员更新")
    @RequestMapping(value="/updateSalariedStaff", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public @ResponseBody  Object updateSalariedStaff(SalariedStaff salariedStaff){
		salariedStaffService.updateSalariedStaff(salariedStaff);
		return ajaxDoneSuccess("数据操作成功 ");
    }
	
	//@RequiresPermissions(value="salariedStaff:deletSalariedStaff",desc="授薪人员删除")
    @RequestMapping(value="/deletSalariedStaff", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public @ResponseBody  Object deletSalariedStaff(Long id){
		salariedStaffService.deletSalariedStaff(id);
		return ajaxDoneSuccess("数据操作成功 ");
    }
    @RequestMapping(value="/setSalariedStaffEnabled", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public @ResponseBody  Object setSalariedStaffEnabled(@ListParam(Long.class)List<Long> ids,Boolean  enabled){
    	salariedStaffService.setEnabled(ids,enabled);
		return ajaxDoneSuccess("数据操作成功 ");
    }
}